package com.wrk._2_数组._02_习题;

import java.util.Arrays;

public class _006_求最小元素的下标 {
    public static void main(String[] args) {
        //定义数组
        int[] array = {10,3,15,26,1,23,2};
        //求出最小元素
        int min =array[0];
        for (int i = 1; i < array.length; i++) {
            if (array[i] < min){
                min = array[i];
            }
        }
        System.out.println("最小元素为："+min);
        //在求最小元素下标
        int index;
        for ( index =0; index < array.length; index++) {
            if (array[index] == min) {
                break;
            }
        }
        System.out.println("最小元素下标为："+index);
    }
}
